import { defineComponent, defineQuery, hasComponent, type Entity, type IWorld } from './ecs';
import { log } from './log';

export const Player = defineComponent('Player', {});

export const playerQuery = defineQuery([Player]);

export const getPlayer = (world) => {
  return playerQuery(world)[0];
};

export const logPlayer = (world: IWorld, e: Entity, msg: string, style?: string) => {
  if (hasComponent(world, Player, e)) {
    log(msg, style);
  }
};
